var elementForAction ;
function expand(){
	if (event.keyCode == 13){
		elementForAction = window.event.srcElement;
	} else {
		elementForAction = window.event.srcElement.parentElement;
	}

	var tempHTML;

	cursorx=elementForAction.offsetLeft;
	elementForAction.style.display="none";
	elementForAction.nextSibling.style.display="inline";

	var sUrl = getUrl (elementForAction.parentElement.parentElement.lastChild);

	var contextUrl = contextRoot + "common/OutlinerContainer.jsp";
	tempHTML = showModalDialog ( contextUrl ,  sUrl , "dialogHeight:45px;dialogWidth:310px;status:no;help:no;scroll:no") ;
	if (tempHTML === undefined) 
		tempHTML = "Action Cancelled.";

	elementForAction.parentElement.parentElement.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.firstChild.innerHTML = tempHTML;

	
	elementForAction.parentElement.parentElement.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.firstChild.style.display="inline";
}

function collapse(){
	if (event.keyCode == 13){
		elementForAction = window.event.srcElement;
	} else {
		elementForAction = window.event.srcElement.parentElement;
	}
	elementForAction.style.display="none";
	elementForAction.previousSibling.style.display="inline";
	
	if (elementForAction.parentElement.parentElement.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.firstChild.innerHTML != null)
		elementForAction.parentElement.parentElement.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.firstChild.innerHTML = "";
	elementForAction.parentElement.parentElement.nextSibling.nextSibling.firstChild.nextSibling.nextSibling.firstChild.style.display="none";
}

function getUrl(p_elementForAction){

	var sKey1 , sKey2, sKey3, sKey4 , sRestrict, sretrievalSearch;

	var sTd = p_elementForAction.getElementsByTagName("SPAN");
	var sUrl = sTd[0].innerText;

	if (sTd[1].innerText != "" ) {
		sKey1 = "&key1=" + sTd[1].innerText;
	} else {
		sKey1 = "";			
	}
	
	if (sTd[2].innerText != "" ) {
		sKey2 = "&key2=" + sTd[2].innerText;
	} else {
		sKey2 = "";			
	}

	if (sTd[3].innerText != "" ) {
		sKey3 = "&key3=" + sTd[3].innerText;
	} else {
		sKey3 = "";			
	}

	if (sTd[4].innerText != "" ) {
		sKey4 = "&key4=" + sTd[4].innerText;
	} else {
		sKey4 = "";			
	}
	
	if (sTd[5].innerText != "" ) {
		ssearchSelect = "&searchselect=" + sTd[5].innerText;
	} else {
		ssearchSelect = "";			
	}
	
	if (sTd[6].innerText != "" ) {
		sretrievalSearch = "&retrievalSearch=" + sTd[6].innerText;
	} else {
		sretrievalSearch = "";			
	}
	
	sRestrict = "";
	var optionspresent = document.getElementById("optionspresent").value;

	if (optionspresent == "true" || optionspresent == "hidden"){
		var optionstable = document.getElementById ("outlineroptions");
		var checkbox = optionstable.getElementsByTagName("INPUT");
		var appendchar = "&";
		
		var j = checkbox.length;
		
		for (i=0;i<j;i++){
			
				if (checkbox[i].checked == true){
					
					if (sRestrict == "")
						sRestrict = sRestrict + appendchar + "view=";

					sRestrict += checkbox[i].value;
				}
		}

	}
	return sUrl + sKey1 + sKey2 + sKey3 + sKey4 + ssearchSelect + sretrievalSearch + sRestrict;
}

function launch(sUrl){
	try {
		// Try to use Master.js function to open window.
		parent.launchWindow(sUrl);
	} catch (e) {
		// For some reason the function is not accessible, launch window anyways
		window.open(sUrl,"_blank","left=0,top=0,titlebar=no,menubar=no,scrollbars=yes,status=yes,resizable=yes");
	}
}


function refreshOutliner(){

var oObject = document.all.item("closegif");

if (oObject != null){
   if (oObject.length != null){
      for (i = 0; i < oObject.length; i++){
         if (oObject(i).parentElement.style.display != "hidden")
         	oObject(i).fireEvent ("onclick");
      }
   }
   else{
// Do nothing since Ticklers always stays expanded
//         if (oObject(i).parentElement.style.display != "hidden")
//         	oObject(i).fireEvent ("onclick");
   }
} 
return;		
}

	// This function is not needed anymore	
	function selectItem(p_item){
		var optionstable = document.getElementById ("outlineroptions");
		var checkbox = optionstable.getElementsByTagName("INPUT");
		var j = checkbox.length;
	
		for (i=0;i<j;i++){
			if (p_item.search(checkbox[i].value) >= 0 ){
				checkbox[i].checked=true;
			} else {
				checkbox[i].checked=false;
			}
		}
	}
	
	function selectRow(p_currenttr){
		try{
			if (p_currenttr.firstChild.nextSibling.firstChild.style.display == "none" ) {
				p_currenttr.firstChild.nextSibling.lastChild.focus();
			} else {
				p_currenttr.firstChild.nextSibling.firstChild.focus();
			}
		} catch (e) {
			// Do nothing. This is prevent javascript errors on the page
		}
	}
	